﻿using System;
using System.ComponentModel;
using System.Windows;
using Groovy_IM.ViewModels.ChatPage;
using Groovy_IM.ViewModels.IMPage;

namespace Groovy_IM.Assets.Messages
{
    public class Message : INotifyPropertyChanged
    {
        public MainMessageViewModel mViewModel = new MainMessageViewModel();

        public PeopleViewModel pViewModel = new PeopleViewModel();
        
        public IMMessageViewModel iViewModel = new IMMessageViewModel();

        private int _Account;

        public int Account
        {
            get { return _Account; }
            set { _Account = value; NotifyPropertyChanged("Account"); }
        }

        private string _Tag;

        public string Tag
        {
            get { return _Tag; }
            set { _Tag = value; NotifyPropertyChanged("Tag"); }
        }

        private bool _isChat;

        public bool IsChat
        {
            get
            {
                return _isChat;
            }
            set
            {
                _isChat = value;
                NotifyPropertyChanged("IsChat");
            }
        }

        private Uri _chatIcon;

        public Uri ChatIcon
        {
            get
            {
                return _chatIcon;
            }
            set
            {
                _chatIcon = value;
                NotifyPropertyChanged("ChatIcon");
            }
        }

        private Uri _Protocol;

        public Uri Protocol
        {
            get
            {
                return _Protocol;
            }
            set
            {
                _Protocol = value;
                NotifyPropertyChanged("Protocol");
            }
        }

        private string _lastMessage;

        public string LastMessage
        {
            get 
            { 
                return _lastMessage; 
            }
            set
            {
                _lastMessage = value;
                NotifyPropertyChanged("LastMessage");
            }
        }

        private string _RMeta;

        public string RMeta
        {
            get
            {
                return _RMeta;
            }
            set
            {
                _RMeta = value;
                NotifyPropertyChanged("RMeta");
            }
        }

        private string _RScreenname;

        public string RScreenname
        {
            get
            {
                return _RScreenname;
            }
            set
            {
                _RScreenname = value;
                NotifyPropertyChanged("RScreenname");
            }
        }

        private string _Screenname;

        public string Screenname
        {
            get 
            {
                return _Screenname; 
            }
            set
            {
                _Screenname = value;
                NotifyPropertyChanged("Screenname");
            }
        }

        private Uri _userStatus;

        public Uri UserStatus
        {
            get
            {
                return _userStatus;
            }
            set
            {
                _userStatus = value;
                NotifyPropertyChanged("UserStatus");
            }
        }

        private Visibility _collapseVisibility = Visibility.Visible;

        public Visibility CollapseVisibility
        {
            get 
            { 
                return _collapseVisibility; 
            }
            set
            {
                _collapseVisibility = value;
                NotifyPropertyChanged("CollapseVisibility");
            }
        }

        public Message(int Acc, string BuddyName, string RealBuddyName, string RealMeta, string LMessage, Uri CProtocol, Uri Icon, Uri BStatus)
        {
            Account = Acc;
            Screenname = BuddyName;
            LastMessage = LMessage;
            Protocol = CProtocol;
            ChatIcon = Icon;
            UserStatus = BStatus;
            RScreenname = RealBuddyName;
            RMeta = RealMeta;
        }

        public event PropertyChangedEventHandler PropertyChanged;
        
        protected void NotifyPropertyChanged(string thePropertyName)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(thePropertyName));
            }
        }
    }
}
